/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package HouseBN;

import DataAccess.DataOperations;
import entity.Payment;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Istc
 */
public class PaymentDB {
    Connection conn;

    public PaymentDB() {
        conn=new DataOperations().getConnection();
    }
    
    public void addPayment(Payment pay)
    {
        try {
            PreparedStatement state = conn.prepareStatement("insert into Payment values (?,?,?,?)");
            state.setString(1, pay.getIdHouse());
            state.setString(2, pay.getIdUser());
            state.setDate(3, new Date(pay.getDate().getTime()));
            state.setFloat(4, pay.getAmount());
            state.executeUpdate();
        } catch (SQLException ex) {
            Logger.getLogger(PaymentDB.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
}

